package com.my.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBCon {
    public static final String url = "jdbc:mysql://localhost:3306/db_hbook?charcterEncoding=utf8";
    public static final String name = "com.mysql.cj.jdbc.Driver";
    public static final String vser = "root";
    public static final String password = "password";
    private Connection con;


    public Connection getConnection() {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            con = DriverManager.getConnection("dbc:mysql://localhost:3306/db_hbook?charcterEncoding=utf8","root","123456");
        } catch (ClassNotFoundException e) {
                // TODO Auto-gennerated catch block
            e.printStackTrace();
        }catch (SQLException e) {
            e.printStackTrace();
        }
        return con;
    }
    public static void main(String[] args) {
        DBCon db = new DBCon();
        System.out.println("con=" + db.getConnection());
    }
}
